# Confluence Quick Start Connector

This package is a utility for connecting Cohere to Confluence, featuring a simple local development setup.

## Limitations

The Confluence connector will search within the space defined in your `.env`, and performs a case-insensitive full-text
search against all text fields Confluence indexes by default. 

Note: The search uses Confluence's advanced search language called [CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/). If you wish to customize this connector's search experience, please refer to the above linked documentation for more details.

## Configuration

This connector requires the following environment variables:

```
CONFLUENCE_USER: User email address
CONFLUENCE_API_TOKEN: API token
CONFLUENCE_PRODUCT_URL: URL to your Confluence instance, including https:// schema
CONFLUENCE_SPACE_NAME: Name of a space within your Confluence wiki
```

The API token can be generated by logging into Confluence and going
to the [API tokens page](https://id.atlassian.com/manage-profile/security/api-tokens).
### Optional Configuration

```
CONFLUENCE_SEARCH_LIMIT
```

This variable can be used to limit the number of results returned by the connector.
By default, the connector will return 10 results.

```
CONFLUENCE_CONNECTOR_API_KEY
```

This variable can be used to set an API key for the connector.

These variables can optionally be put into a `.env` file for development.
A `.env-template` file is provided with all the environment variables that are used by this demo.

## Development

Create a virtual environment and install dependencies with poetry. We recommend using in-project virtual environments:

```bash
  $ poetry config virtualenvs.in-project true
  $ poetry install --no-root
```

To load some test documents into Confluence, this repo provides a `load_data.py` script in `dev/`.

```bash
  $ poetry shell
  $ python dev/load_data.py
```

Next, start up the connector's server:

```bash
  $ poetry run flask --app provider --debug run --port 5000
```

and check with curl to see that everything works:

```bash
  curl --request POST \
    --url http://localhost:5000/search \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <CONNECTOR_API_KEY>' \
    --data '{
      "query": "BBQ"
    }'
```

Alternatively, load up the Swagger UI and try out the API from a browser: http://localhost:5000/ui/
